<!DOCTYPE html>
<html lang="en" xmlns:th="http://www.thymeleaf.org/">
<head>
	<meta http-equiv="Content-Type" content="text/html;charset=UTF-8">
	<title>天天生鲜-购物车</title>
	<link rel="stylesheet" type="text/css" th:href="@{/css/reset.css}">
	<link rel="stylesheet" type="text/css" th:href="@{/css/main.css}">
</head>
<body>
	<div th:replace="top::top"></div>

	<div class="total_count">全部商品<em>2</em>件</div>	
	<ul class="cart_list_th clearfix">
		<li class="col01">商品名称</li>
		<li class="col02">商品单位</li>
		<li class="col03">商品价格</li>
		<li class="col04">数量</li>
		<li class="col05">小计</li>
		<li class="col06">操作</li>
	</ul>
	<th:block th:each="cartVO:${list}">
		<ul th:id="${cartVO.id}" class="cart_list_td clearfix">
			<li class="col01">
				<input th:onclick="|updateChecked(${cartVO.id}, this.checked)|" th:checked="${cartVO.checked==1}" type="checkbox" name="">
				<!--
				<th:block th:if="${cartVO.checked==1}">
					<input th:onclick="|updateChecked(${cartVO.id}, this.checked)|" checked type="checkbox" name="">
				</th:block>
				<th:block th:if="${cartVO.checked==0}">
					<input th:onclick="|updateChecked(${cartVO.id}, this.checked)|" type="checkbox" name="">
				</th:block>-->
			</li>
			<li class="col02"><img width="100px" height="100px" th:src="|${cartVO.productMainImage}|"></li>
			<li class="col03"><span th:text="${cartVO.productName}"></span><br><em>25.80元/500g</em></li>
			<li class="col04">500g</li>
			<li class="col05" th:text="|${cartVO.productPrice}元|"></li>
			<li class="col06">
				<div class="num_add">
					<a href="javascript:;" class="add fl">+</a>
					<input th:value="${cartVO.quantity}" type="text" class="num_show fl" value="1">
					<a href="javascript:;" class="minus fl">-</a>
				</div>
			</li>
			<li class="col07">25.80元</li>
			<li class="col08"><a th:onclick="|deleteById(${cartVO.id})|" href="javascript:;">删除</a></li>
		</ul>
	</th:block>


	<ul class="settlements">
		<li class="col01"><input type="checkbox" name="" checked=""></li>
		<li class="col02">全选</li>
		<li class="col03">合计(不含运费)：<span>¥</span><em>42.60</em><br>共计<b>2</b>件商品</li>
		<li class="col04"><a href="/order/getOrderConfirmPage">去结算</a></li>
	</ul>

	<div class="footer">
		<div class="foot_link">
			<a href="#">关于我们</a>
			<span>|</span>
			<a href="#">联系我们</a>
			<span>|</span>
			<a href="#">招聘人才</a>
			<span>|</span>
			<a href="#">友情链接</a>		
		</div>
		<p>CopyRight © 2016 北京天天生鲜信息技术有限公司 All Rights Reserved</p>
		<p>电话：010-****888    京ICP备*******8号</p>
	</div>

	<script type="text/javascript" th:src="@{/jquery-2.1.4.js}"></script>
	<script type="text/javascript" th:src="@{/layer/layer.js}"></script>
	<script type="text/javascript" th:src="@{/mylayer.js}"></script>
	<script>
		function deleteById(id) {
			console.log('deleteById id: ' + id);
			$.post(
				'/cart/deleteById',
				{'id': id},
				function(result) {
					//"我"+age+"岁了"
					if (result.code == 0) {
						$('#'+id+'').remove();
						mylayer.okMsg(result.msg);
					} else {
						mylayer.errorMsg(result.msg);
					}
				},
				'json'
			);
		}

		function updateChecked(id, checked) {
			console.log('id: ' + id);
			console.log('checked: ' + checked);
			$.post(
				'/cart/updateChecked',
				{'id': id, 'checked': checked ? 1 : 0},
				function(result) {
					if (result.code == 0) {
						mylayer.okMsg(result.msg);
					} else {
						mylayer.errorMsg(result.msg);
					}
				},
				'json'
			);
		}
	</script>
</body>
</html>